package com.wen.pojo;

import com.wen.utils.DateUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

/**
 * (Product)实体类
 *
 * @author makejava
 * @since 2021-02-14 17:56:09
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Product implements Serializable {
    private static final long serialVersionUID = -58000956935811367L;
    /**
     * 无意义，主键uuid
     */

    private String id;

    /**
     * 产品编号
     */

    private String productNum;

    /**
     * 产品名称(路线名称)
     */

    private String productName;

    /**
     * 出发城市
     */

    private String cityName;

    /**
     * 出发时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    private Date departureTime;
    private String departureTimeStr;
    /**
     * 产品价格
     */

    private Double productPrice;

    /**
     * 产品描述
     */

    private String productDesc;

    /**
     * 状态(0关闭1开启)
     */

    private Integer productStatus;
    private String productStatusStr;
    private Integer tempId;  //订单编辑功能，数据回显所需的id
    public String getDepartureTimeStr() {
        if (departureTime != null) {
            departureTimeStr = DateUtils.date2String(departureTime, "yyyy-MM-dd HH:mm:ss");
        }
        return departureTimeStr;
    }

    public String getProductStatusStr() {
        if (productStatus == 1) {
            productStatusStr = "开启";
        } else {
            productStatusStr = "关闭";

        }
        return productStatusStr;
    }
}